home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / boxes / aboutsg / aboutbox.bas next >
Encoding:
BASIC Source File  |  1995-03-03  |  5.4 KB  |  146 lines

  1. Option Explicit
  2. ' Any program that includes this file must also include ABOUTBOX.TXT.
  3. '
  4. ' The AB_NO_xxxx constants are used to exclude informational lines
  5. ' from the About Box display.  You pass one or more of them, combined
  6. ' using OR, as the last parameter to DisplayAboutBox.
  7. Global Const AB_NO_USER = &H1
  8. Global Const AB_NO_COMPANY = &H2
  9. Global Const AB_NO_WINVER = &H4
  10. Global Const AB_NO_DOSVER = &H8
  11. Global Const AB_NO_WINMODE = &H10
  12. Global Const AB_NO_MEMORY = &H20
  13. Global Const AB_NO_80x87 = &H40
  14. Global Const AB_NO_FSR = &H80
  15.  
  16. Global Excl% ' Global variable holds bit flags for excluded items.
  17.  
  18.  
  19. ' GetSystemMetrics returns the size (in pixels) of various on-screen
  20. ' items.  There are many more SM_xxxx constants besides those defined
  21. ' below.  The About Box uses the sizes to set its position on screen.
  22. Declare Function GetSystemMetrics% Lib "User" (ByVal nIndex%)
  23. Global Const SM_CYCAPTION = &H4
  24. Global Const SM_CYMENU = &HF
  25. Global Const SM_CXSIZE = &H1F
  26.  
  27. ' API functions used in getting user and company name
  28. Declare Function LoadLibrary% Lib "Kernel" (ByVal LibFileName$)
  29. Declare Sub FreeLibrary Lib "Kernel" (ByVal hInst%)
  30. Declare Function LoadString% Lib "User" (ByVal hInst%, ByVal idResource%, ByVal Buffer$, ByVal cBuffer%)
  31.  
  32. ' GetVersion returns both Windows and DOS versions
  33. Declare Function GetVersion& Lib "Kernel" ()
  34.  
  35. ' GetWinFlags returns a Long that's filled with bit-flags providing
  36. ' information about Windows.  We use only 3 of its 13 flags
  37. Declare Function GetWinFlags& Lib "Kernel" ()
  38. Global Const WF_PMODE = &H1
  39. Global Const WF_ENHANCED = &H20
  40. Global Const WF_80x87 = &H400
  41.  
  42. ' GetFreeSpace returns the amount of free memory
  43. Declare Function GetFreeSpace& Lib "Kernel" (ByVal wFlags%)
  44.  
  45. ' Free System Resources are a special kind of memory that can run out
  46. ' before your main memory runs out.
  47. Declare Function GetFreeSystemResources% Lib "User" (ByVal fuSysResource%)
  48. Global Const GFSR_SYSTEMRESOURCES = 0
  49. Global Const GFSR_GDIRESOURCES = 1
  50. Global Const GFSR_USERRESOURCES = 2
  51.  
  52. Sub DisplayAboutBox (F As Form, ByVal ProgName$, ByVal Version, ByVal CoprDate, ByVal CoprName$, ByVal Ex1$, ByVal Ex2$, ByVal Exclude%, ByVal Center%, ByVal Fore&, ByVal Back&)
  53. 'Your program simply calls this function to display an about box.
  54. 'F         - the main form of the calling program, used to get an
  55. '            icon for display and to position the about box.
  56. 'ProgName  - program name, for caption and first line
  57. 'Version   - version number, displayed as 0.00
  58. 'CoprDate  - copyright year
  59. 'CoprName  - copyright holder's name
  60. 'Ex1       - extra data line 1 (optional)
  61. 'Ex2       - extra data line 2 (optional)
  62. 'Exclude   - used to exclude info from the about box.  AB_NO_xxxx
  63. '            constants are bit-flags for this parameter.  e.g. to
  64. '            exclude displaying DOS & Windows versions, pass
  65. '            AB_NO_DOSVER OR AB_NO_WINVER
  66. 'Center    - if TRUE, About box is centered on screen; if FALSE, About
  67. '            box is displayed offset from calling window.
  68. 'Fore,Back - foreground and background colors for box; 0 to use default
  69.   Excl = Exclude
  70.   Load FAB
  71.   Dim N%
  72.   If Fore Then
  73.     FAB.ForeColor = Fore
  74.     FAB.CoprLabel.ForeColor = Fore
  75.     FAB.MyInfoLabel.ForeColor = Fore
  76.     FAB.NameLabel.ForeColor = Fore
  77.     For N = 0 To 14
  78.       FAB.OptLabel(N).ForeColor = Fore
  79.     Next N
  80.     FAB.Shape1.BorderColor = Fore
  81.   End If
  82.   If Back Then
  83.     FAB.BackColor = Back
  84.     FAB.CommandOK.BackColor = Back
  85.     FAB.CoprLabel.BackColor = Back
  86.     FAB.IconPicture.BackColor = Back
  87.     FAB.NameLabel.BackColor = Back
  88.     FAB.MyInfoLabel.BackColor = Back
  89.     FAB.Shape1.FillColor = Back
  90.     For N = 0 To 14
  91.       FAB.OptLabel(N).BackColor = Back
  92.     Next N
  93.   End If
  94.   If Center Then
  95.     FAB.Left = (Screen.Width - FAB.Width) \ 2
  96.     FAB.Top = (Screen.Height - FAB.Height) \ 2
  97.   Else
  98.     ' Place the About box over the calling window, offset downward
  99.     ' and to the right
  100.     Dim Tmp% ' variable to keep lines of code from becoming TOO long
  101.     Tmp = GetSystemMetrics(SM_CXSIZE)
  102.     FAB.Left = F.Left + Tmp * Screen.TwipsPerPixelX
  103.     Tmp = GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYMENU)
  104.     FAB.Top = F.Top + Tmp * Screen.TwipsPerPixelY
  105.     ' If about box now extends off the screen, move it back ON
  106.     If FAB.Left + FAB.Width > Screen.Width Then
  107.       FAB.Left = Screen.Width - (FAB.Width + 30)
  108.     End If
  109.     If FAB.Top + FAB.Height > Screen.Height Then
  110.       FAB.Top = Screen.Height - (FAB.Height + 30)
  111.     End If
  112.   End If
  113.   FAB.IconPicture.Picture = F.Icon
  114.   FAB.Caption = "About " + ProgName$
  115.   Dim Temp$ ' variable to keep lines of code from becoming TOO long
  116.   Temp = ProgName$ + ", Version " + Format$(Version, "0.00")
  117.   FAB.NameLabel.Caption = Temp
  118.   Temp = "Copyright ⌐ " + CoprDate + " by " + CoprName
  119.   FAB.CoprLabel.Caption = Temp
  120.   If Ex1 = "" Then
  121.     EliminateLabel 0
  122.   Else
  123.     FAB.OptLabel(0).Caption = Ex1
  124.   End If
  125.   If Ex2 = "" Then
  126.     EliminateLabel 1
  127.   Else
  128.     FAB.OptLabel(1).Caption = Ex2
  129.   End If
  130.   FAB.Show
  131. End Sub
  132.  
  133. Sub EliminateLabel (ByVal Which%)
  134.   ' If one of the informational labels in the about box is not wanted,
  135.   ' make it invisible and move all the other labels up to fill in the
  136.   ' space.  Then shrink the form as well.
  137.   FAB.OptLabel(Which).Visible = False
  138.   Dim N%, H%
  139.   H = FAB.OptLabel(0).Height
  140.   For N = Which + 1 To 14
  141.     FAB.OptLabel(N).Top = FAB.OptLabel(N).Top - H
  142.   Next N
  143.   FAB.Height = FAB.Height - H
  144. End Sub
  145.  
  146.